<%@ page language="java" import="java.util.*,cn.ac.cintcm.dataconverge.researchsubject.domain.*" pageEncoding="UTF-8"%>
<%@page import="com.hs.core.page.PageUtil,com.hs.core.utils.*,cn.ac.cintcm.dataconverge.researcher.domain.*"%>
<%@page import="cn.ac.cintcm.dataconverge.util.Constants;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
PageUtil pageUtil = (PageUtil)request.getAttribute("mysubjectList");
List resultList = null;
String pageStr = ""; 
int perpageCount = 1;
int currentPage = 1;
if(null != pageUtil){
   resultList = pageUtil.getPageList();
   pageStr = pageUtil.getPageStr();
   perpageCount = pageUtil.getNumberPerPage();
   currentPage = pageUtil.getCurrentPage();
}
String subjectname = (String)request.getAttribute("subjectname");
String startdate = (String)request.getAttribute("startdate");
String enddate = (String)request.getAttribute("enddate");
String startyear = (String)request.getAttribute("startyear");
String endyear = (String)request.getAttribute("endyear");
String snumber = (String)request.getAttribute("snumber");
String status = (String)request.getAttribute("status");

String onreserach = (String)request.getAttribute("onreserach");
String onpermit = (String)request.getAttribute("onpermit");
String finishSubject = (String)request.getAttribute("finishSubject");

String orderName = (String)request.getAttribute("orderName");
String orderNum = (String)request.getAttribute("orderNum"); 
String orgId = (String)request.getAttribute("orgId"); 
List orgList = (List)request.getAttribute("orgList");
List dictList = (List)request.getAttribute("dictList");
String subjectUser = (String)request.getAttribute("subjectUser");
 
String studyDict = (String)request.getAttribute("studyDict");
String isDoc = (String)request.getAttribute("isDoc");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>课题信息</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <link href="<%=path%>/index/Themes/com/style.css" rel="stylesheet" type="text/css" /> 
    <script src="<%=path%>/index/Scripts/Script.js" language="javascript" type="text/javascript"></script>
     <script src="<%=path%>/js/common.js" language="javascript" type="text/javascript"></script>
       <script src='<%=basePath%>dwr/engine.js'></script>
     <script src='<%=basePath%>dwr/util.js'></script> 
     <script src='<%=basePath%>dwr/interface/subject.js'></script>
   
    <script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
    <script language="javascript" type="text/javascript">
       function delSubject(id){
       		if(null != id && id != '' ){
       		 	if(confirm("确认删除课题?")){
       		 		form1.action = '<%=path%>/subjectToAdd.htm?action=delSubject&id='+id;
       		 		form1.submit();
       		 	}
       		}
       
       }
       
       function searchSubject(){  
       			searchform.submit();			
       }
       var selectSubjectId = '';
       function submitAudit(subjectId){
          if(confirm('课题提交审批后将不能修改，确认提交?')){
	          if('' != subjectId){
	          	subject.submitAudit(subjectId,submitCallback)
	            selectSubjectId = subjectId;
	          }  
	      }
       }
       function submitCallback(message){
         if("0" == message){
            alert("课题提交审批失败");
         }
          if("1" == message){
            document.getElementById('status_' + selectSubjectId).innerHTML='申报中';
            document.getElementById('oper_' + selectSubjectId).innerHTML='';
            alert("课题提交审批成功");
         }
       }
       function uploadFile(){
            var subs = document.getElementsByName("subjectId");
            var subjectId = "0";
            if(subs != null && subs.length>0){
	            for(var index=0;index<subs.length;index++){
	            	if(subs[index].checked)
	            		subjectId = subs[index].value;
	            }
            } 
            if('0' != subjectId)
       			openwindow('<%=path %>/document.htm?action=uploadView&subjectId='+subjectId,'600','400','');
       			else
       			alert("请选择要添加文档的课题");
       
       }
       function deleteFile(fileId){
           if(confirm("确人要删除该文件？")){
                form1.action = "<%=path %>/document.htm?action=delete&fileId="+fileId;
                form1.submit();
           }
       
       
       }
    </script>

</head>
<body class="rtm_body" scroll=yes>
<form name="searchform" action = "<%=path%>/subject.htm?action=listMySubjectFileList" method="post">
    <div class="r_rtm_tb_mg1">
        <div class="r_rtm_tb1">
            <span>
                <img src="<%=path%>/index/Themes/com/idt_tb_pass.gif" />&nbsp;&nbsp;课题文档</span>
        </div>
    </div>  
     <table cellspacing="2" cellpadding="0" width="100%" class="idt_item_mg" id="Table2">
         <tr>
            <td class="fim_l" width="10%">
                项目名称：</td>
            <td class="fim_r" width="25%">
                <input type="text" name="subjectname" value="<%=subjectname==null?"":subjectname %>" class="com_textbox" ></td>
            <!-- td class="fim_l">
                申报日期：</td>
            <td class="fim_r" nowrap width="30%">
                从
               <input type="text" class="Wdate" id="startdate" value="<%=startdate==null?"":startdate %>" style="width:40%" name="startdate"  onFocus="WdatePicker({el:'startdate',dateFmt:'yyyy-MM-dd'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="enddate" value="<%=enddate==null?"":enddate %>" style="width:40%" name="enddate"  onFocus="WdatePicker({el:'enddate',dateFmt:'yyyy-MM-dd'})" />
            </td-->
            <td class="fim_l" width="10%">
                参与单位：</td>
            <td class="fim_r" nowrap width="25%">
               <select name="orgId" style="width:100%">
                <option value=""></option>
                <%
                
                 if(orgList.size()>0){ 
                	 for(int i =0;i<orgList.size();i++){
                		 Organization org = (Organization)orgList.get(i);
                		 out.print("<option value=");
                		 out.print(org.getId());
                		 if((org.getId()+"").equals(orgId))
                		 	out.print(" selected");
                		 out.print(">");
                		 out.print(org.getName());
                		 out.print("</option>");
                	 }
                 }
                %>
                </select>
            </td>
            <td class="fim_r" align="right" colspan="2">
                
                
            </td>
        </tr>
        <tr>
            <td class="fim_l">
                负责人：</td>
            <td class="fim_r">
                <input type="text" name="subjectUser" value="<%=subjectUser==null?"":subjectUser %>" class="com_textbox" ></td>
            
            <td class="fim_l">
                状态：</td>
            <td class="fim_r" nowrap width="30%">
               <select name="status" style="width:100%">
                 <option value="-1">----请选择----</option>
                  <option value="<%=Constants.subject_state_save%>" <%if((""+Constants.subject_state_save).equals(status)){out.println(" selected");} %>>未审核</option>
                 <option value="<%=Constants.subject_state_checked%>" <%if((""+Constants.subject_state_checked).equals(status)){out.println(" selected");} %>>审核中</option> 
                  <option value="<%=Constants.subject_state_researching%>" <%if((""+Constants.subject_state_researching).equals(status)){out.println(" selected");} %>>已审核</option>
                  
                   <option value="<%=Constants.subject_state_ended%>" <%if((""+Constants.subject_state_ended).equals(status)){out.println(" selected");} %>>已结题</option> 
                 
                </select>  
            </td>
            <td class="fim_r" align="right" colspan="2">
                <input type="submit" value="查询"  onclick="searchSubject()" class="com_btn2" id="Button5">
                <!-- input type="button" value="高级查询"   onclick="if(AdCheckForm.style.display=='none')AdCheckForm.style.display='';else AdCheckForm.style.display='none';"
                    class="com_btn2" id="Button1"-->
                 <input type="button" value="上传文档"   onclick="uploadFile();"
                    class="com_btn2" id="Button1">
                
            </td>
        </tr>
        <!-- tr id="AdCheckForm" style="display: none;">
            <td class="fim_l">
                课题编号：</td>
            <td class="fim_r">
                <input type="text" class="com_textbox" id="snumber" value="<%=snumber==null?"":snumber %>" name="snumber"></td>
            <td class="fim_l">
                所属年份：</td>
            <td class="fim_r">
                从
               <input type="text" class="Wdate" id="startyear" value="<%=startyear==null?"":startyear %>" style="width:40%" name="startyear"  onFocus="WdatePicker({el:'startyear',dateFmt:'yyyy'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="endyear" value="<%=endyear==null?"":endyear %>" style="width:40%" name="endyear"  onFocus="WdatePicker({el:'endyear',dateFmt:'yyyy'})" />
            </td>
             <td class="fim_l">
              是否有附件： </td>
            <td class="fim_r"> 
                  <select name="isDoc" style="width:100%">
                  <option value=""> </option>
                  <option value="0" <%if("0".equals(isDoc)){ out.println(" selected");} %>>有附件</option>
                  <option value="1" <%if("1".equals(isDoc)){ out.println(" selected");} %>>无附件</option>
                  
                  </select>
            </td>
        </tr-->
        </form>
    </table> 
   
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                <div class="content">
                 <form name="form1" action="" method="post">
                    <table width="*" cellpadding="0" cellspacing="1" class="dg_borderstyle" id="Table4">
                        <tr>
                           <td class="dg_headerstyle">
                                选择</td>
                            <td class="dg_headerstyle">
                                序号</td>
                            
                            <td class="dg_headerstyle" width="20%">
                                <a href="javaScript:orderPage('subjectname','<%=OrderTool.getOrderNum("subjectname",orderName,orderNum)%>');">课题名称&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("subjectname",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('state','<%=OrderTool.getOrderNum("state",orderName,orderNum)%>');">当前状态&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("state",orderName,orderNum))%></a></td>
                            
                            
                            <td class="dg_headerstyle"><a href="javaScript:orderPage('applydate','<%=OrderTool.getOrderNum("applydate",orderName,orderNum)%>');">填报日期&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("applydate",orderName,orderNum))%></a></td>
                                
                            <td class="dg_headerstyle">
                                文档类型</td> 
                                <td class="dg_headerstyle">
                                文档名称</td> 
                                  <td class="dg_headerstyle">
                                上传人</td>
                                <td class="dg_headerstyle">
                                上传日期</td>
                                <td class="dg_headerstyle">
                                操作</td>
                                  
                           
                        </tr>
                        <%if(null != resultList && resultList.size()> 0){
                            for(int i = 0;i < resultList.size();i++){
                                    Subject obj = (Subject)resultList.get(i); 
                                    Set accSet = obj.getAccessorys();
                                    int rows = 0;
                                    if(null != accSet)
                                       rows = accSet.size();
                                    
                         %>
                        <tr class="dg_alternatingitemstyle" onmouseover="ChangeRowBg(this);" onmouseout="ChangeRowBg(this);" onmouseup="ChangeRowBg(this);" onmousedown="ChangeRowBg(this);">
                            <td width="3%" align="center" rowspan="<%=rows %>"><input type="radio" name="subjectId" value="<%=obj.getId() %>"/></td>
                            <td width="5%" align="center" rowspan="<%=rows %>"><%= perpageCount*(currentPage-1)+i+1 %></td>
                            
                            <td width="15%" rowspan="<%=rows %>">
                                <a href="#"   onclick="openwindow('<%=path %>/subjectToAdd.htm?action=viewSubject&id=<%=obj.getId() %>','','','')"> <%=StringUtilTool.NULL2Blank(obj.getSubjectname()) %></a>
                            </td>
                            <td align="center" rowspan="<%=rows %>" width="5%">
                                <font color="red"><span id="status_<%=obj.getId() %>"><%=Constants.getSubjectStatus(obj.getState()) %></span></font>
                            </td> 
                             
                            <td align="center" rowspan="<%=rows %>" width="6%"><%=Tools.getDateStringByDate1(obj.getApplydate()) %></td>
                            <%  
                             if(null != accSet && accSet.size()!=0){  
                            		Iterator iter = accSet.iterator();
                            		int index = 0;
                            		while(iter.hasNext()){
                            		   		index ++;
                            		   		ResmanDocument rd = (ResmanDocument)iter.next();
                            		   	    if(index ==1){ 
                             %>    
                                            <td><%=rd.getDictType()==null?"":rd.getDictType().getName()%></td>
                                             <td><%=rd.getTitle()==null?"":rd.getTitle() %></td>
                                            <td><%=rd.getUploadUser()==null?"":rd.getUploadUser().getName() %></td>
                                            <td width="6%"><%=Tools.getDateStringByDate1(rd.getUploaddate()) %></td>
                                            <td align="center"><a href="<%=path %>/document.htm?action=downloadFile&fileId=<%=rd.getId() %>">下载</a>&nbsp;&nbsp;<a href="javaScript:deleteFile('<%=rd.getId() %>')">删除</a></td>
                                            </tr> 
                                            <%}else{ %>
                                             <tr class="dg_alternatingitemstyle">
                                               
                                            <td><%=rd.getDictType()==null?"":rd.getDictType().getName()%></td>
                                             <td><%=rd.getTitle()==null?"":rd.getTitle() %></td>
                                            <td><%=rd.getUploadUser()==null?"":rd.getUploadUser().getName() %></td>
                                            <td width="6%"> <%=Tools.getDateStringByDate1(rd.getUploaddate()) %> </td>
                                            <td align="center"><a href="<%=path %>/document.htm?action=downloadFile&fileId=<%=rd.getId() %>">下载</a>&nbsp;&nbsp;<a href="javaScript:deleteFile('<%=rd.getId() %>')">删除</a></td>
                                            </tr> 
                                            <%} %>
                             
                             <%}}else{%> 
		                        <td colspan="5" align="center"> 
		                               <font color=red>该项目当前没有附件！</font>
		                        </td>
		                       </tr> 
                            <%}%>  
                        <%}}else{%>
                         <tr class="dg_alternatingitemstyle"> 
                            <td align="center" colspan=11>
                                <font color="red">没有找到记录</font>
                            </td> 
                        </tr> 
                        <%}%>
                    </table>
                    </form>
                    <div class="dg_pagerstyle" align="right"> 
                            <%=pageStr %>  
                    </div>
                    
                </div>
            </td>
        </tr>
    </table>
</body>
</html>
